package com.xinli.business.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinli.business.domain.TQuestionReply;
import com.xinli.business.domain.TQuestionReplyComment;
import com.xinli.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xinli.business.mapper.LfCommentMapper;
import com.xinli.business.domain.LfComment;
import com.xinli.business.service.ILfCommentService;

/**
 * 用户评论Service业务层处理
 *
 * @author ruoyi
 * @date 2025-04-29
 */
@Service
public class LfCommentServiceImpl extends ServiceImpl<LfCommentMapper,LfComment>  implements ILfCommentService
{
    @Autowired
    private LfCommentMapper lfCommentMapper;

    /**
     * 查询用户评论
     *
     * @param id 用户评论主键
     * @return 用户评论
     */
    @Override
    public LfComment selectLfCommentById(Long id)
    {
        return lfCommentMapper.selectLfCommentById(id);
    }

    /**
     * 查询用户评论列表
     *
     * @param lfComment 用户评论
     * @return 用户评论
     */
    @Override
    public List<LfComment> selectLfCommentList(LfComment lfComment)
    {
        return lfCommentMapper.selectLfCommentList(lfComment);
    }

    /**
     * 新增用户评论
     *
     * @param lfComment 用户评论
     * @return 结果
     */
    @Override
    public int insertLfComment(LfComment lfComment)
    {
                lfComment.setCreateTime(DateUtils.getNowDate());
            return lfCommentMapper.insertLfComment(lfComment);
    }

    /**
     * 修改用户评论
     *
     * @param lfComment 用户评论
     * @return 结果
     */
    @Override
    public int updateLfComment(LfComment lfComment)
    {
        return lfCommentMapper.updateLfComment(lfComment);
    }

    /**
     * 批量删除用户评论
     *
     * @param ids 需要删除的用户评论主键
     * @return 结果
     */
    @Override
    public int deleteLfCommentByIds(Long[] ids)
    {
        return lfCommentMapper.deleteLfCommentByIds(ids);
    }

    /**
     * 删除用户评论信息
     *
     * @param id 用户评论主键
     * @return 结果
     */
    @Override
    public int deleteLfCommentById(Long id)
    {
        return lfCommentMapper.deleteLfCommentById(id);
    }



    @Override
    public void setQuestionReplyCount(LfComment reply)
    {
        QueryWrapper<LfComment> wrapper = new QueryWrapper<>();
        wrapper.eq("post_id",reply.getPostId());
        wrapper.eq("pid",reply.getId());
        wrapper.eq("type",2);
        long count = this.count(wrapper);
        reply.setPlCount(count);
    }

}
